<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue@next"></script>
    <!-- 
        编写一个ToList小例子,了解循环和双向绑定
    
     -->
</head>
<body>
    
    <div id="root"></div>

    <!-- vue实例 -->
    <script>
        const app = Vue.createApp({
            data() {
                return {
                    // list: ['hello','world','dell','lee']
                    list:[],
                    inputValue: ''
                }
            },
            methods: {
                btnAdd: function(){
                    this.list.push(this.inputValue);
                    this.inputValue = ''
                }
            },
            template: `
            <div>
                <input v-model="inputValue"/>
                <button v-on:click="btnAdd" v-bind:title="inputValue">增加</button>
            <ul>
                <li v-for="(item,index) of list">{{index}}->{{item}}</li>
            </ul>
            </div>
            `
        }).mount('#root');
    </script>
</body>
</html>